<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <script src="{$Think.config.httpFlag}{$Think.config.google_map_url}" async="async"></script>
</head>

<body>
<div class="layui-fluid main">

    <div style="display: inline-block;width: 35%">
        <fieldset class="layui-elem-field site-demo-button" style="margin-top:20px;border:0">
            <h2><strong>{if !empty($name)}{$name}{/if}</strong></h2>
        </fieldset>
        <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">

            <form class="layui-form serch" action="/admin/poi/airport/id/{$id}.shtml" method="post">
                <div class="layui-form-item" style="float: left;">
                    <div class="layui-input-inline">
                        <input type="text" name="cityname" lay-verify="title" autocomplete="off" placeholder="请输入机场名称" class="layui-input layui-btn-sm">
                    </div>
                    <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">搜索</button>
                    <a href="{:url('admin/poi/addairport',['groupid'=>$id])}" class="layui-btn layui-btn-sm a_menu">
                        新增机场
                    </a>
                    <a href="{:url('admin/poi/airportadmin')}" class="layui-btn layui-btn-sm">
                        返回列表
                    </a>
                </div>
            </form>
        </fieldset>
        <table class="layui-table"  lay-even="" lay-skin="line">
            <colgroup>
                <col width="100">
                <col width="300">
                <col width="300">
                <col width="200">
            </colgroup>
            <thead>
            <tr >
                <th>ID</th>
                <th>机场名称</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>

            {volist name="poi" id="vo"}
            <tr class="seemap" codeid="{$vo.id}">
                <td>{$vo.id}</td>
                <td ><strong>{$vo.name}</strong><br/>{$vo.eng_name}</td>
                <td>{$vo.update_time}</td>
                <td class="operation-menu">
                    <a href="{:url('admin/poi/addairport',['id'=>$vo.id])}" class="layui-btn layui-btn-xs a_menu" style="margin-left: 0;font-size:12px;">修改</a>
                    <a class="layui-btn layui-btn-xs layui-btn-danger delete" data-id="{$vo.id}" style="margin-left: 0;font-size:12px;">删除</a>
                </td>
            </tr>
            {/volist}

            </tbody>
        </table>
    </div>


    <div class="right75" style="width: 60%;margin: 10px 0">
        <div style="margin: 10px 0"><h2 id="poiname">{if $poiname}{$poiname}{/if}</h2><span class="color666" id="poieng_name">{if $poieng_name}{$poieng_name}{/if}</span></div>
        <div style="margin: 10px  0" id="introduce">
            {if $introduce}{$introduce}{/if}
        </div>
        <hr>
        <div>
            <strong>联系方式：</strong><span id="mobile">{if $mobile}{$mobile}{/if}</span>
        </div>
        <hr>

        <div>
            <strong>特别说明：</strong>
            <span id="description">{if $description}{$description}{/if}</span>
        </div>
        <hr>
        <div id="map" style="height: 500px;width: 100%">

        </div>
        <hr>
        <div style="margin: 10px  0" id="thumb">

            {volist name="$thumb" id="vo"}
            {if !empty($vo)}
            <span class="uploadimgbox"><img class="layui-upload-img" src="{$vo}"></span>
            {/if}
            {/volist}
        </div>
    </div>
</div>
<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script type="text/javascript">
    layui.use('layer', function(){
        var layer = layui.layer;
        $('.a_menu').click(function(){
            var url = $(this).attr('href');
            var a = 0;
            $.ajax({
                url:url
                ,async:false
                ,success:function(res){
                    if(res.code == 0) {
                        layer.msg(res.msg);
                        a = 1;
                    }
                }
            })
            if(a === 0) {
                layer.open({
                    type:2,
                    content:url,
                    area: ['80%', '80%'],
                    end:function(){
                        location.reload();
                    }
                });
            }
            return false;
        })

        $('.preview').click(function(){
            var url = $(this).attr('href');
            layer.open({
                type:2,
                content:url,
                area: ['60%', '60%']
            });
            return false;
        })

    });
    $(".seemap").click(function () {
        var id = $(this).attr('codeid');
        $.ajax({
            url:"{:url('admin/poi/seepoimap')}",
            data:{id:id},
            success:function(res) {
                if(res.code == 1) {
                    var data=res.data;
                    $("#description").html(data[0].description);
                    $("#poiname").html(data[0].name);
                    $("#poieng_name").html(data[0].eng_name);
                    $("#introduce").html(data[0].introduce);
                    $("#mobile").html(data[0].mobile);
                    initialize(data[0].lat,data[0].lng);
                }else{
                    layer.msg(res.msg);
                }
            }
        })
    })


    $('.delete').click(function(){
        var id = $(this).attr('data-id');
        layer.confirm('确定要删除?', function(index) {
            $.ajax({
                url:"{:url('admin/poi/delpoi')}",
                type:"post",
                data:{id:id},
                success:function(res) {
                    layer.msg(res.msg);
                    if(res.code == 1) {
                        setTimeout(function(){
                            location.href = res.url;
                        },1500)
                    }
                }
            })
        })
    })
</script>
<script type="text/javascript">
    //地图功能
    var geocoder;
    var map2;
    var marker=new google.maps.Marker();
    function initialize(lat,lng) {
        geocoder = new google.maps.Geocoder();
        var myOptions = {
            zoom : 10,//缩放比例
            center:new google.maps.LatLng(lat,lng),
            mapTypeId : google.maps.MapTypeId.ROADMAP
        };
        map2 = new google.maps.Map(document.getElementById("map"),
            myOptions);
        marker.setMap(null);
        marker = new google.maps.Marker({
            map : map2,
            position :new google.maps.LatLng(lat,lng),
            //坐标动画效果
            animation : google.maps.Animation.DROP
        });
        marker.setMap(map2);
    }

    initialize({$latlng[0]},{$latlng[1]});

</script>
</body>
</html>
